using System;
using System.Collections.Generic;
using Common;

namespace DRE.Item {
	public class Manager : IRegisterManager<Item> {
		readonly Dictionary<string, Item> items = new Dictionary<string, Item>();
		public bool IsExists(string id) => items.ContainsKey(id);
		public void Register(Item item) {
			if (IsExists(item.Id)) {
				throw new ArgumentException("An item with the same ID: " + item.Id + " is already registered!");
			}
			items.Add(item.Id, item);
		}
		public void Clear() => items.Clear();
		public Item Get(string id) => IsExists(id) ? items[id] : null;
		public void Remove(string id) => items.Remove(id);
		public Item this[string id] => Get(id);
	}
	public abstract class Item : IRegisterable {
		public enum UseTarget {
			Individual,
			Everyone
		}

		public abstract string Id { get; }
		public virtual string Name { get; }
		public virtual string Description { get; }
		public virtual string ShortDescription { get; }
		public virtual UseTarget UseType { get; } = UseTarget.Individual;
		public virtual string AvailableTarget { get; } = "";

		//Equipment properties
		public virtual float Attack { get; } = 0;
		public virtual float Defense { get; } = 0;
		public virtual float Magic { get; } = 0;
		public virtual string Ability { get; } = "None";
		public virtual float GrazeAmountFactor { get; } = 1;
		public virtual float GrazeSizeFactor { get; } = 1;
		public virtual float Value { get; } = 0;

		public virtual void OnUse(Inventory.Position position, string[] targetCharacters) {

		}
		public virtual void OnToss(Inventory.Position position) {

		}
		public virtual void OnEquip(Inventory.Position from, Character.EquipmentPosition to) {

		}
		public virtual void OnUnequip(Character.EquipmentPosition from, Inventory.Position to) {

		}
	}
}